<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <title>首页</title>
    <th:block th:replace="~{commons/commons::head}"/>
    <script src="/static/js/httpVueLoader/httpVueLoader.js"></script><!--vue.js-->
    <script src="/static/js/vue/vue.min.js"></script><!--vue.js-->
    <script src="/static/js/page.min.js"></script>
</head>
<body>
<div id="index">
    <h1>首页</h1>
    <a href="/logout">退出登录</a>   |   <a href="#" @click="clearAuthenticationCache">刷新认证</a>   |   <a href="#" @click="clearAuthorizationCache">刷新授权</a>

    <p th:text="${msg}"></p>
    <!--<p th:text="'欢迎：' + ${session.LoginInfo.username}"></p>-->
    <p>欢迎：<shiro:principal/></p>

    <hr>
    <a th:href="@{/user/add}">add</a> | <a shiro:hasRole="admin" th:href="@{/user/update}">update</a>
<br>
    <a th:href="@{/shiro/role}">需要admin角色编程式</a> | <a th:href="@{/shiro/zhujie}">需要admin角色注解式</a>


<!--
    <ul>
        <li>用户类&#45;&#45;角色
            <ul shiro:hasAnyRoles="admin,user">
                <li><a href="#">添加</a></li>
                <li><a href="#">删除</a></li>
                <li><a href="#">修改</a></li>
                <li><a href="#">查询</a></li>
            </ul>
        </li>
        <li>用户类&#45;&#45;权限
            <ul>
                <li shiro:hasPermission="user:add:*"><a href="#">添加</a></li>
                <li shiro:hasPermission="user:delete:*"><a href="#">删除</a></li>
                <li shiro:hasPermission="user:update:*"><a href="#">修改</a></li>
                <li shiro:hasPermission="user:find:*"><a href="#">查询</a></li>
            </ul>
        </li>
        <li>学生类
            <ul>
                <li shiro:hasPermission="student:add:*"><a href="#">添加</a></li>
                <li shiro:hasPermission="student:delete:*"><a href="#">删除</a></li>
                <li shiro:hasPermission="student:update:*"><a href="#">修改</a></li>
                <li shiro:hasPermission="student:find:*"><a href="#">查询</a></li>
            </ul>
        </li>
        <li>文件类
            <ul>
                <li shiro:hasPermission="file:add:*"><a href="#">添加</a></li>
                <li shiro:hasPermission="file:delete:*"><a href="#">删除</a></li>
                <li shiro:hasPermission="file:update:*"><a href="#">修改</a></li>
                <li shiro:hasPermission="file:find:*"><a href="#">查询</a></li>
            </ul>
        </li>
    </ul>-->

</div>
<script>
    let index = new Vue({
        el : '#index',
        data : {
            username : 'admin',
        },
        methods : {
            clearAuthorizationCache(){
                axios.get('/clearAuthorizationCache')
                    .then( (response) => {
                        if (response.data === true){
                            Qmsg.info("授权刷新成功");
                        }else{
                            Qmsg.info("授权刷新失败");
                        }
                    })
                    .catch( (error) => {
                        console.log(error);
                    });
            },
            clearAuthenticationCache(){
                axios.get('/clearAuthenticationCache')
                    .then( (response) => {
                        if (response.data === true){
                            Qmsg.info("认证刷新成功");
                        }else{
                            Qmsg.info("认证刷新失败");
                        }
                    })
                    .catch( (error) => {
                        console.log(error);
                    });
            },
        },
        beforeMount (){//页面挂载之前
            /*消息弹窗全局配置*/
            Qmsg.config({
                showClose:true,
                timeout:2000,
                position:'center',
                autoClose:false
            })
        },
        mounted(){//页面挂载之后
        },
    });

</script>

</body>
</html>
